package com.why.cachecloud.client.spectator.config;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Component
public class CacheCloudConstants {

    @Resource
    private CacheCloudConfig config;

    public static String DOMAIN_URL;
    public static String CLIENT_VERSION;
    public static String REDIS_CLUSTER_URL;
    public static String REDIS_SENTINEL_URL;
    public static String REDIS_STANDALONE_URL;
    public static String CACHECLOUD_EXP_REPORT_URL;
    public static String CACHECLOUD_COMMAND_REPORT_URL;

    public static int HTTP_CONN_TIMEOUT;
    public static int HTTP_SOCKET_TIMEOUT;


    @PostConstruct
    public void init() {
        DOMAIN_URL = config.getDomainName();
        CLIENT_VERSION = config.getClientVersion();
        HTTP_CONN_TIMEOUT = config.getHttpConnTimeout();
        HTTP_SOCKET_TIMEOUT = config.getHttpSocketTimeout();
        REDIS_CLUSTER_URL = DOMAIN_URL + "/cache/client/redis/cluster/%s.json?clientVersion=" + CLIENT_VERSION;
        REDIS_SENTINEL_URL = DOMAIN_URL + "/cache/client/redis/sentinel/%s.json?clientVersion=" + CLIENT_VERSION;
        REDIS_STANDALONE_URL = DOMAIN_URL + "/cache/client/redis/standalone/%s.json?clientVersion=" + CLIENT_VERSION;
        CACHECLOUD_EXP_REPORT_URL = DOMAIN_URL + "/cachecloud/client/v1/reportData/exception";
        CACHECLOUD_COMMAND_REPORT_URL = DOMAIN_URL + "/cachecloud/client/v1/reportData/command";
    }
}
